/**
 * Created by: "Nicola Garegnani"
 * 01/mar/2013
 */
package com.hexworks.main;

import java.util.Hashtable;

public class CombinatoriaBis {

	// grandezza della regione in relazione ai numeri m
	// nel caso con 4 abbiamo tutte le 24 permutazioni?
	private static final int A = 100;
	private static final double B = Math.E / A;
	private static final int N = 4;

	private static Hashtable<String, String> counterString = new Hashtable<String, String>();

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		int a = A;
		double b = 0;
		int m = A;
		int incrementChecker = 0;

		StringBuilder composite = new StringBuilder();
		String appender = new String();

		// do {
		for (b = A + Math.E / A; b <= (m * A); b = b + B) {
			if (b > a) {
				appender = "ab";
				a++;
			} else
				appender = "b";

			// System.out.println(b + " a= " + a + " c= " + c + " " + appender);
			composite.append(appender);
		}
		System.out.println("With A_n=" + A + " , B_n=" + B + " String length: " + composite.length());
		System.out.println(composite);
		String working = composite.toString();

		for (int i = 1; i <= N; i++) {
			for (int j = 0; j < working.length() - i; j++) {
				counterString.put(working.substring(j, j + i), working.substring(j, j + i));
			}
			// for (String s : counterString.keySet()) {
			// System.out.println(s);
			// }
			System.out.println("k=" + i + " abbiamo " + counterString.size()
					+ " stringhe diverse\tDifference: \t" + (counterString.size() - incrementChecker));
			incrementChecker = counterString.size();
			counterString.clear();
		}
		m = m + 10;
		// } while (incrementChecker != 21 && m < (Integer.MAX_VALUE / 100));
		// float rapport = (float) (((m) * C) / A);
		// System.out.println("Con m=" + A + " la regione è " + rapport * A + "("
		// + (m - 10) + ") rapporto="
		// + rapport);
	}
}